#include <iostream>
#include <stdio.h>

#include <iostream>
#include <memory>
#include <vector>

using namespace std;

class Solution
{
public:
    int Search(vector<int> &nums, int target)
    {
        int left = 0;
        int right = nums.size();

        while (left <= right)
        {
            int mid = left + ((right - left) >> 1);
            if (nums[mid] > target)
            {
                right = mid - 1;
            }
            else if (nums[mid] < target)
            {
                left = mid + 1;
            }
            else
            {
                return mid;
            }
        }

        return -1;
    }
};

int main(int argv, char **argc)
{

    printf("************  test hello zc!!!   **************\n");
    /* add test code! */
    vector<int> vecs = {1, 0, 3, 5, 9, 12};

    Solution solution;
    int ret = solution.Search(vecs, 9);

    if (-1 == ret)
    {
        printf("can,t find target!!!\n");
    }else{
        printf("find target[%d]!!!\n", ret);
    }

    return 0;
}
